<template>
<div class="baobao">
    <div class="img">
        <img src="https://img1.ceramicschina.com/upload/images/2019-10-22/20191022125045360.jpg" alt="" width="100%">
    </div>
    <div class="btn">
        <span :class="{active: currentIndex == index }" v-for="(item, index) in btnArr" :key="index" @click="changeStatus(index)">{{ item }}</span>
    </div>
        <div class="lt" v-for="(item, index) in listArr" :key="index">
    <img :src="item.picture" alt="" width="120px" height="120px" />
    <span class="title">{{ item.name }}</span>
    <br />
    <span class="des">{{ item.unit }}</span>
    <br />
    <span class="bb">爆爆团价</span>
    <br />
    <span class="price">￥{{ item.min_price }}</span>
    <br />
    <span class="qiang">马上抢</span>
    <div>
        <span class="orign"><del>￥100</del></span>
        <span class="sum">已售{{ item.month_saled }}份</span>
    </div>
    </div>
</div>
</template>

<script>
import axios from "axios";
export default {
    data() {
        return {
        currentIndex: 0,
        btnArr: ["即将开抢", "正在抢购"],
        listArr: [],
        };
    },
    mounted() {
        axios
        .get("/api/tuan/list", {
            params: {
            status: this.currentIndex,
            },
        })
        .then((res) => {
            this.listArr = res.data.list;
        });
    },
    beforeUpdate() {
            axios
            .get("/api/tuan/list", {
                params: {
                status: this.currentIndex,
                },
            })
            .then((res) => {
                this.listArr = res.data.list;
            });
        },
    methods: {
        changeStatus(index) {
        this.currentIndex = index;
        },
    },
    };
</script>

<style lang='scss' scoped>
.baobao {
    width: 100%;
}
.baobao .img {
    width: 100%;
    height: 100px;
}
.btn {
    width: 100%;
    display: flex;
    justify-content: space-around;
    height: 40px;
    background-color: orangered;
    margin-bottom: 20px;
    margin-top: 50px;
}
.btn span {
    font-weight: bolder;
    line-height: 40px;
}
.btn .active{
    color: lightskyblue;
}

.lt {
    width: 96%;
    height: 150px;
    margin: auto;
    background-color: #f5f5f5;
    border-radius: 10px;
    position: relative;
    margin-bottom: 10px;
}

.lt img {
    margin: 15px 10px;
    float: left;
}
.lt .title {
    display: inline-block;
    font-size: 12px;
    color: #888;
    margin-top: 15px;
}
.lt .des {
    font-weight: bold;
    font-size: 20px;
}
.lt .bb {
font-size: 12px;
    color: orange;
}
.lt .price {
    color: red;
    font-size: 20px;
}
.lt .qiang {
    background-color: orangered;
    padding: 5px 15px;
    border-radius: 20px;
    color: white;
    font-size: 14px;
    position: absolute;
    right: 10px;
    top: 65px;
}
.lt > div {
    font-size: 12px;
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
}
.lt > div > .orign {
    color: #999;
}
.lt > div > .sum {
    color: red;
    margin-right: 20px;
}
</style>